home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2004 May / SGI IRIX 6.5 Applications 2004 May.iso / dist / java3d.idb / usr / demos / java / j3d / programs / examples / PickTest / OctahedronTFA.java.z / OctahedronTFA.java
Encoding:
Java Source  |  2003-08-08  |  3.4 KB  |  108 lines

  1. /*
  2.  *    @(#)OctahedronTFA.java 1.8 02/04/01 15:03:40
  3.  *
  4.  * Copyright (c) 1996-2002 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Redistribution and use in source and binary forms, with or without
  7.  * modification, are permitted provided that the following conditions
  8.  * are met:
  9.  *
  10.  * - Redistributions of source code must retain the above copyright
  11.  *   notice, this list of conditions and the following disclaimer.
  12.  *
  13.  * - Redistribution in binary form must reproduce the above copyright
  14.  *   notice, this list of conditions and the following disclaimer in
  15.  *   the documentation and/or other materials provided with the
  16.  *   distribution.
  17.  *
  18.  * Neither the name of Sun Microsystems, Inc. or the names of
  19.  * contributors may be used to endorse or promote products derived
  20.  * from this software without specific prior written permission.
  21.  *
  22.  * This software is provided "AS IS," without a warranty of any
  23.  * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
  24.  * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
  25.  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
  26.  * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
  27.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  28.  * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
  29.  * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
  30.  * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
  31.  * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
  32.  * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
  33.  * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  34.  *
  35.  * You acknowledge that Software is not designed,licensed or intended
  36.  * for use in the design, construction, operation or maintenance of
  37.  * any nuclear facility.
  38.  */
  39.  
  40. import javax.media.j3d.*;
  41. import javax.vecmath.*;
  42.  
  43. class OctahedronTFA extends TriangleFanArray {
  44.   private static final int[] sVertCnt = {
  45.     6, 6
  46.   };
  47.  
  48.   OctahedronTFA() {
  49.     super(12, GeometryArray.COORDINATES | GeometryArray.COLOR_3, sVertCnt);  
  50.     
  51.     Point3f verts[] = new Point3f[6];
  52.     Color3f colors[] = new Color3f[6];
  53.     
  54.     verts[0] = new Point3f(0.0f,0.0f,-1.5f);
  55.     verts[1] = new Point3f(0.0f,0.0f,1.5f);
  56.     verts[2] = new Point3f(0.0f,-1.5f,0.0f);
  57.     verts[3] = new Point3f(0.0f,1.5f,0.0f);
  58.     verts[4] = new Point3f(1.5f,0.0f,0.0f);
  59.     verts[5] = new Point3f(-1.5f,0.0f,0.0f);
  60.  
  61.     colors[0] = new Color3f(1.0f, 0.0f, 0.0f);
  62.     colors[1] = new Color3f(0.0f, 1.0f, 0.0f);
  63.     colors[2] = new Color3f(0.0f, 0.0f, 1.0f);
  64.     colors[3] = new Color3f(1.0f, 1.0f, 0.0f);
  65.     colors[4] = new Color3f(1.0f, 0.0f, 1.0f);
  66.     colors[5] = new Color3f(0.0f, 1.0f, 1.0f);
  67.  
  68.     
  69.     Point3f pnts[] = new Point3f[12];
  70.     Color3f clrs[] = new Color3f[12];
  71.  
  72.     pnts[0] = verts[4];
  73.     clrs[0] = colors[4];
  74.     pnts[1] = verts[2];
  75.     clrs[1] = colors[2];
  76.     pnts[2] = verts[0];
  77.     clrs[2] = colors[0];
  78.     
  79.     pnts[3] = verts[3];
  80.     clrs[3] = colors[3];
  81.  
  82.     pnts[4] = verts[1];
  83.     clrs[4] = colors[1];    
  84.     
  85.     pnts[5] = verts[2];
  86.     clrs[5] = colors[2];
  87.  
  88.     pnts[6] = verts[5];
  89.     clrs[6] = colors[5];
  90.     pnts[7] = verts[1];
  91.     clrs[7] = colors[1];
  92.     pnts[8] = verts[3];
  93.     clrs[8] = colors[3];
  94.  
  95.     pnts[9] = verts[0];
  96.     clrs[9] = colors[0];
  97.  
  98.     pnts[10] = verts[2];
  99.     clrs[10] = colors[2];
  100.  
  101.     pnts[11] = verts[1];
  102.     clrs[11] = colors[1];
  103.  
  104.     setCoordinates(0, pnts);
  105.     setColors(0, clrs);
  106.   }
  107. }
  108.